﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.Xml;
using System.IO;

namespace DLL
{
    class DLL
    {
        //Code in the DLL that accepts three input parameters: the Generic object type holding the data to save, the filename to save, and the serializer object
        public static bool WriteXML(object savedObj, string fileToSave, XmlSerializer serializer)
        {
            try
            {
                TextWriter textWriter = new StreamWriter(fileToSave);
                serializer.Serialize(textWriter, savedObj);
                textWriter.Close();
                return true;
            }
            catch (Exception ex)
            {
                Utility.LogFile(ex.ToString());
                return false;
            }
        }

        //Code in RAD, COM, or MIS app to call the WriteXML DLL static method
        XmlSerializer serializer = new XmlSerializer(typeof(Bogey));  //You can replace Bogey with any type you are trying to serialize
        XMLHandler.WriteXML(Bog_Obj, "Bogey_Serialzed.xml", serializer); //You can replace "Bogey_Serialzed.xml" with the file name needed
    }
}
